<!DOCTYPE HTML>
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
<link href="lib/Hui-iconfont/1.0.6/iconfont.css" rel="stylesheet" type="text/css" />
<link href="lib/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>新增广告位</title>
</head>
<body>
	<div class="pd-20">
		<form action="<%=path%>/backstage/advert_position-add" method="post"
			class="form form-horizontal" id="form-u_advert_position-add">
			<input type="hidden" id="id" name="id"
			value='${u_advert_position.id}' />

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">位置名：</label>
				<div class="formControls col-xs-8 col-sm-5">
					<input type="text" class="input-text"
					value="${u_advert_position.position_name}" placeholder="" id=""
					autocomplete="off" name="position_name" datatype="*"
					nullmsg="不能为空">
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">外页示意图：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<div id="fileList_pre_picture" class="uploader-list">
						<c:if test="${!empty u_advert_position.pre_picture}">
						<div class="file-item thumbnail upload-state-done">
							<img style="width:200px;height:200px;" src="${u_advert_position.pre_picture}" />
							<div class="info"></div>
						</div>
					</c:if>
				</div>
				<div id="filePicker_pre_picture">选择图片</div>
				<input type="hidden" class="input-text"
				value="${u_advert_position.pre_picture}" placeholder=""
				id="pre_picture" name="pre_picture"/>
			</div>
		</div>

		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">单价：</label>
			<div class="formControls col-xs-8 col-sm-5">
				<input type="text" class="input-text"
				value="${u_advert_position.unit_price}" placeholder="" id=""
				name="unit_price" datatype="n" nullmsg="不能为空">
			</div>
			<div class="formControls col-sm-4">元/天</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">外页尺寸说明：</label>
			<div class="formControls col-xs-4 col-sm-5">
				<input type="text" class="input-text"
				value="${u_advert_position.spec}" placeholder="" id="" name="spec"
				datatype="*" nullmsg="不能为空">
			</div>
			<div class="formControls col-sm-4">eg: 尺寸 500px*500px 格式 .png</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">内页示意图：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<div id="fileList_pre_prcture_inn" class="uploader-list">
					<c:if test="${!empty u_advert_position.pre_picture}">
					<div class="file-item thumbnail upload-state-done">
						<img style="width:200px;height:200px;" src="${u_advert_position.pre_prcture_inn}" />
						<div class="info"></div>
					</div>
				</c:if>
			</div>
			<div id="filePicker_pre_prcture_inn">选择图片</div>
			<input type="hidden" class="input-text"
			value="${u_advert_position.pre_prcture_inn}" placeholder=""
			id="pre_prcture_inn" name="pre_prcture_inn">
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3">内页尺寸说明：</label>
		<div class="formControls col-xs-8 col-sm-5">
			<input type="text" class="input-text"
			value="${u_advert_position.spec_inn}" placeholder="" id=""
			name="spec_inn" datatype="*" nullmsg="不能为空">
		</div>
		<div class="formControls col-sm-4">eg: 尺寸 500px*500px 格式 .png</div>
	</div>

	<div class="row cl">
		<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
			<button onClick="u_advert_position_save_submit();"
			class="btn btn-primary radius" type="submit">
			<i class="Hui-iconfont">&#xe632;</i> 保存并提交
		</button>
		<button onClick="layer_close();" class="btn btn-default radius"
		type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
	</div>	
</form>
</div>
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/layer/2.1/layer.js"></script>
<script type="text/javascript" src="lib/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="lib/icheck/jquery.icheck.min.js"></script>
<script type="text/javascript"
src="lib/Validform/5.3.2/Validform.min.js"></script>
<script type="text/javascript"
src="lib/webuploader/0.1.5/webuploader.min.js"></script>
<script type="text/javascript"
src="lib/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript"
src="lib/ueditor/1.4.3/ueditor.all.min.js"> </script>
<script type="text/javascript"
src="lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" src="js/H-ui.js"></script>
<script type="text/javascript" src="js/H-ui.admin.js"></script>
<script type="text/javascript">

	function u_advert_position_save_submit(){

		$("#form-u_advert_position-add").Validform({
			tiptype:2,
			ajaxPost:true,
			callback:function(form){
				var index = parent.layer.getFrameIndex(window.name);
			if (index){//关闭弹出层
				parent.$('.btn-refresh').click(); 
				parent.layer.close(index);
			}else{//单独的页面
				location.href = "<%=path%>/backstage/u_advert_position-list"; 
			}
		}
	});
	}

// 图片上传demo
$(function() {
	/*外页上传*/
	var $list = $('#fileList_pre_picture'),
	$list_pre_prcture_inn = $('#fileList_pre_prcture_inn'),
	ratio = window.devicePixelRatio || 1,
	thumbnailWidth = 100 * ratio,
	thumbnailHeight = 100 * ratio,
	uploader,uploader_pre_prcture_inn;

	uploader = WebUploader.create({
		auto: true,
		swf: 'lib/webuploader/0.1.5/Uploader.swf',
		server: '<%=path%>/backstage/common/uploadPic',
		pick: '#filePicker_pre_picture',
		
		formData : {
			foldername : 'advert'
		}
	});

	uploader.on( 'fileQueued', function( file ) {
		var $li = $(
			'<div id="' + file.id + '" class="file-item thumbnail">' +
			'<img>' +
			'<div class="info">' + file.name + '</div>' +
			'</div>'
			),
		$img = $li.find('img');

		$list.html($li);
		uploader.makeThumb( file, function( error, src ) {
			if ( error ) {
				$img.replaceWith('<span>不能预览</span>');
				return;
			}

			$img.attr( 'src', src );
		}, thumbnailWidth, thumbnailHeight );
	});

	uploader.on( 'uploadSuccess', function(file, response) {
		$( '#'+file.id ).addClass('upload-state-done');
		$("#pre_picture").val(response.datas);
	});

	uploader.on( 'uploadError', function( file ) {
		var $li = $( '#'+file.id ),
		$error = $li.find('div.error');
		if ( !$error.length ) {
			$error = $('<div class="error"></div>').appendTo( $li );
		}

		$error.text('上传失败');
	});

	uploader.on( 'uploadComplete', function( file ) {
		$( '#'+file.id ).find('.progress').remove();
	});

	/*内页上传*/
	uploader_pre_prcture_inn = WebUploader.create({
		auto: true,
		swf: 'lib/webuploader/0.1.5/Uploader.swf',
		server: '<%=path%>/backstage/common/uploadPic',
		pick : '#filePicker_pre_prcture_inn',
		accept : {
			title : 'Images',
			extensions : 'gif,jpg,jpeg,bmp,png',
			mimeTypes : 'image/jpg,image/jpeg,image/png'
		},
		formData : {
			foldername : 'advert'
		}
	});

	uploader_pre_prcture_inn
	.on(
		'fileQueued',
		function(file) {
			var $li = $('<div id="' + file.id + '" class="file-item thumbnail">'
				+ '<img>'
				+ '<div class="info">'
				+ file.name + '</div>' + '</div>'), $img = $li
			.find('img');

			$list_pre_prcture_inn.html($li);
			uploader_pre_prcture_inn
			.makeThumb(
				file,
				function(error, src) {
					if (error) {
						$img
						.replaceWith('<span>不能预览</span>');
						return;
					}

					$img.attr('src', src);
				}, thumbnailWidth,
				thumbnailHeight);
		});

	uploader_pre_prcture_inn.on('uploadSuccess', function(file,
		response) {
		$('#' + file.id).addClass('upload-state-done');
		$("#pre_prcture_inn").val(response.datas);
	});

	uploader_pre_prcture_inn.on('uploadError', function(file) {
		var $li = $('#' + file.id), $error = $li.find('div.error');
		if (!$error.length) {
			$error = $('<div class="error"></div>').appendTo($li);
		}

		$error.text('上传失败');
	});

	uploader_pre_prcture_inn.on('uploadComplete', function(file) {
		$('#' + file.id).find('.progress').remove();
	});

});
</script>
</body>
</html>

